package com.alibaba.csp.sentinel.dashboard.rule.database.enums;

public enum DatabaseRuleEnums {
    NONE(0, "未知规则", "none", ""),

    //流控规则
    FLOW_RULE(1, "流控规则", "sentinel-flow-rules", "inMemFlowRuleStore"),

    //降级规则
    DEGRADE_RULE(2, "降级规则", "sentinel-degrade-rules", "inMemDegradeRuleStore"),
    //热点规则
    PARAM_RULE(3, "热点规则", "sentinel-param-flow-rules", "inMemParamFlowRuleStore"),

    //系统规则
    SYSTEM_RULE(4, "系统规则", "sentinel-system-rules", "inMemSystemRuleStore"),
    // 授权规则
    AUTHORITY_RULE(5, "授权规则", "sentinel-authority-rules", "inMemAuthorityRuleStore"),

    ;

    private int code;
    private String name;
    private String describe;
    private String beanName;

    DatabaseRuleEnums(int code, String name, String describe, String beanName) {
        this.code = code;
        this.name = name;
        this.describe = describe;
        this.beanName = beanName;
    }

    public int getCode() {
        return this.code;
    }

    public String getBeanName() {
        return beanName;
    }

    public String getName() {
        return name;
    }

    public String getDescribe() {
        return describe;
    }


    public static DatabaseRuleEnums convert(int code) {
        for (DatabaseRuleEnums t : DatabaseRuleEnums.values()
        ) {
            if (t.getCode() == code) return t;
        }
        return NONE;
    }
}
